package com.enjoyor.soa.traffic.rest.efoms.controller;

import com.enjoyor.soa.traffic.frame.annotation.Auth;
import com.enjoyor.soa.traffic.rest.efoms.dubbo.invoke.DubboCollectRealServiceInvoke;
import com.enjoyor.soa.traffic.rest.efoms.dubbo.invoke.DubboLedProgInfoServiceInvoke;
import com.enjoyor.soa.traffic.rest.efoms.dubbo.invoke.DubboSolrClientInvoke;
import com.enjoyor.soa.traffic.util.pojo.Page;
import com.enjoyor.soa.traffic.util.pojo.ResultPojo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@Auth
@RestController
@RequestMapping({ "/otherSystem" })
@Api("获取其他系统数据(卡口过车、诱导节目等)")
@CrossOrigin
public class OtherSystemDataController {

    @Autowired
    private DubboSolrClientInvoke dubboSolrClientInvoke;
    
    @Autowired
    private DubboLedProgInfoServiceInvoke dubboLedProgInvoke;
    
    @Autowired
    private DubboCollectRealServiceInvoke dubboCollectRealInvoke;
    
    @SuppressWarnings({ "rawtypes" })
	@GetMapping(value = { "/getPageVehSear" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiOperation("查询卡口过车分页信息")
	@ApiImplicitParams({ 
		@ApiImplicitParam(name = "bayonetId", value = "卡口编号", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "token", value = "token", paramType = "query", dataType = "String")})
	public ResultPojo getPageVehSear(
			@RequestParam(defaultValue = "", value = "bayonetId", required = false) String bayonetId,
			@RequestParam(defaultValue = "", value = "startTime", required = false) String startTime,
			@RequestParam(defaultValue = "", value = "endTime", required = false) String endTime,
			@RequestParam(defaultValue = "", value = "token", required = false) String token,
			Page page, HttpServletRequest request) {
    	ResultPojo result = new ResultPojo();
		try {
			result = dubboSolrClientInvoke.getPageVehSear(page, bayonetId, startTime, endTime, token);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return result;
	}

	@GetMapping(value = { "/getOnProgList" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiOperation("根据ledId查询诱导屏当前节目单信息")
    @ApiImplicitParam(name = "ledId", value = "诱导屏编号", paramType = "query", required = true, dataType = "String")
	public ResultPojo getOnProgList(
			@RequestParam(defaultValue = "", value = "ledId", required = true) String ledId,
			HttpServletRequest request) {
    	ResultPojo result = dubboLedProgInvoke.getOnProgList(ledId);
		return result;
	}
	
	@GetMapping(value = { "/getProgList" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiOperation("根据ledId查询诱导屏总节目单信息")
    @ApiImplicitParam(name = "ledId", value = "诱导屏编号", paramType = "query", required = true, dataType = "String")
	public ResultPojo getProgList(
			@RequestParam(defaultValue = "", value = "ledId", required = true) String ledId,
			HttpServletRequest request) {
    	ResultPojo result = dubboLedProgInvoke.getProgList(ledId);
		return result;
	}
	
	@GetMapping(value = { "/getDevWayRealFlow" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiOperation("根据设备ID获取各车道流量数据")
    @ApiImplicitParam(name = "devId", value = "采集设备编号", paramType = "query", required = true, dataType = "String")
	public ResultPojo getDevWayRealFlow(
			@RequestParam(defaultValue = "", value = "devId", required = true) String devId,
			HttpServletRequest request) {
    	ResultPojo result = dubboCollectRealInvoke.getDevWay5MinsFlow(devId);
		return result;
	}
}
